﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UGlue;
using UGlue.Kit;

public class NewBehaviourScript : MonoBehaviour
{
    // Start is called before the first frame update
    void Awake()
    {
        EventBus.Register("测试事件", OnEvent);
        EventBus.Register("测试事件1", OnEvent);
        EventBus.Register("测试事件", OnEvent1);
        UnitTestUI.AddButton("发送事件", () => EventBus.Post("测试事件", 1, "测试1", 22), true);
        UnitTestUI.AddButton("发送事件1", () => EventBus.Post("测试事件1", 1, "测试2", 22), true);
    }

    private void OnEvent(EventBus.EventHead key, params object[] param) {
        Debug.Log("event收到事件:" + key.ToJsonStr() + ", " + param.ToJsonStr());
    }

    private void OnEvent1(EventBus.EventHead key, params object[] param) {
        Debug.Log("event1收到事件:" + key.ToJsonStr() + ", " + param.ToJsonStr());
    }

    private void OnDisable() {
        EventBus.UnRegister("测试事件", OnEvent);
        EventBus.UnRegister("测试事件", OnEvent1);
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
